use ../processed/NLSY79.dta, clear

gen AFQT3_a = max(AFQT3-1/3,0)
gen AFQT3_b = max(AFQT3-2/3,0)
gen age_a = max(age-35,0)
gen age_b = max(age-45,0)
gen female = (sex==2)
local ctrl AFQT3 AFQT3_a AFQT3_b female blk hsp nsibs age age_a age_b i.hgc_m i.hgc_f i.yob i.divisiona locE locU urban
local iv pub4 tui4 locE17 locU17

reg hgc_r `iv' `ctrl' [pw=wgt], cluster(cty_grp)
esttab using "../result/first_stage.txt", b(%6.3f) se(%6.3f) nostar compress replace
ivreg2 logwage (hgc_r=`iv') `ctrl' [pw=wgt], cluster(cty_grp)
weakivtest
file open myfile using "../result/first_stage.txt", write append
file write myfile "Montiel-Pflueger Effective F: " (r(F_eff)) _n
file close myfile
